cmake_minimum_required(VERSION 2.8)

project(software)
set(LIB_VERSION 1.0.0)

include(modules/IdentifyOS.cmake)

set(CMAKE_CXX_FLAGS_DEBUG "-g3 -Wall -g -ggdb -fPIC")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -fPIC")
set(CMAKE_CXX_STANDARD 11)
set(LIB_VERSION 1.0.0)

set(CMAKE_C_FLAGS "-static-libgcc")
set(CMAKE_SKIP_RPATH FALSE)
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "." "/usr/local/sniper/lib")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)

add_definitions(-D__STDC_FORMAT_MACROS)

add_subdirectory(example)

MESSAGE(STATUS "operation system name is ${CMAKE_OS_NAME}")

IF (CMAKE_OS_NAME MATCHES "Ubuntu")
    MESSAGE(STATUS "current platform: Ubuntu ")
    add_definitions(-DUbuntu)

ELSEIF (CMAKE_OS_NAME MATCHES "Debian")
    MESSAGE(STATUS "current platform: Debian")
    add_definitions(-DDebian)

ELSEIF (CMAKE_OS_NAME MATCHES "RedHat")
    MESSAGE(STATUS "current platform: RedHat")
    add_subdirectory(librpmcpp)
    add_definitions(-DRedHat)

ELSE ()
    MESSAGE(STATUS "unknown system!!!")

ENDIF (CMAKE_OS_NAME MATCHES "Ubuntu")

set(CMAKE_INSTALL_PREFIX example)

include_directories(/usr/local/include)
include_directories(/usr/include)
include_directories(.)

aux_source_directory(. SRC_LIST)

link_directories(/usr/local/lib)
link_directories(/usr/lib)

link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)

add_library(${PROJECT_NAME} SHARED ${SRC_LIST})
SET(LIBRARY_OUTPUT_PATH lib)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${LIB_VERSION})

IF (CMAKE_OS_NAME MATCHES "RedHat")
    target_link_libraries(${PROJECT_NAME} rpmcpp)
ENDIF (CMAKE_OS_NAME MATCHES "RedHat")

target_link_libraries(${PROJECT_NAME} boost_regex)

install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib)

